﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Common
{
    public class TabItem: System.Windows.Controls.TabItem
    {
        private ContentControl ElementHeader;
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            ElementHeader = this.GetTemplateChild("Header") as ContentControl;
            if (ElementHeader != null)
            {
                ElementHeader.IsTabStop = true;
            }
        }
        protected override void OnSelected(RoutedEventArgs e)
        {
            base.OnSelected(e);
            try
            {
                ElementHeader.Focus();
            }
            catch { }
        }
    }
}

//Public Class TabItem : Inherits System.Windows.Controls.TabItem

//        Private ElementHeader As ContentControl

//        Public Overrides Sub OnApplyTemplate()
//            MyBase.OnApplyTemplate()
//            Me.ElementHeader = TryCast(Me.GetTemplateChild("Header"), ContentControl)
//            If Me.ElementHeader IsNot Nothing Then ElementHeader.IsTabStop = True
//        End Sub

//        Protected Overrides Sub OnSelected(e As RoutedEventArgs)
//            MyBase.OnSelected(e)

//            Try
//                ElementHeader.Focus()
//            Catch ex As Exception
//                ' nothing
//            End Try
//        End Sub

//    End Class